home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
gnu
/
othergnu
/
gnuplot.zoo
/
atari.trm
< prev
next >
Wrap
Text File
|
1992-03-01
|
7KB
|
284 lines
/* GNUPLOT - atari.trm */
/*
* Copyright (C) 1991
*
* Permission to use, copy, and distribute this software and its
* documentation for any purpose with or without fee is hereby granted,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation.
*
* Permission to modify the software is granted, but not the right to
* distribute the modified code. Modifications are to be distributed
* as patches to released version.
*
* This software is provided "as is" without express or implied warranty.
*
* This file is included by ../term.c.
*
* This terminal driver supports:
* Atari Screens working with the normal VDI
* (this should include TT and big screens)
*
* AUTHORS
* Alexander Lehmann
* 02/13/92 Derived from an unreleased version for GP 2.02
*
* send your comments or suggestions to (pixar!info-gnuplot@sun.com).
*
* ATARI-related comments please to alexlehm@iti.informatik.th-darmstadt.de
* (up to know this is not in the official GP release)
*
*/
#include <aesbind.h>
#include <vdibind.h>
#include <osbind.h>
/* default to hi-res */
#define ATARI_XMAX 640
#define ATARI_YMAX 400
#define ATARI_VCHAR 16
#define ATARI_HCHAR 8
#define ATARI_HTIC (ATARI_XMAX/80)
#define ATARI_VTIC (ATARI_YMAX/80)
#define ATARI_yc(y) (ATARI_maxycoord-y)
static int vdi_handle=-1;
static int ATARI_maxycoord;
static int ATARI_lt;
static int ATARI_rotation;
static int ATARI_numcolors;
static int pxy[128]; /* Maximum of 64 pixels per v_pline */
static int pxy_index;
static int ATARI_colors[16];
static int ATARI_savecolors[16][3];
static int ATARI_numpalette;
ATARI_options( )
{
#define ATARIERROR "palette values 3 hex digit, please"
char opt[4];
int i;
char *tok_end;
term_options[0]='\0';
for( i=0 ; i<16 ; i++ ) {
if(END_OF_COMMAND) break;
if (token[c_token].length>3)
int_error(ATARIERROR, c_token);
capture( opt, c_token, c_token );
ATARI_colors[i]=strtoul( opt, &tok_end, 16 );
if( *tok_end!='\0' )
int_error(ATARIERROR, c_token);
sprintf( opt, "%03X ", ATARI_colors[i] );
strcat( term_options, opt );
c_token++;
}
ATARI_numpalette=i;
}
ATARI_init( )
{
int work_in[11];
int work_out[57];
int i;
int hchar, wchar, dummy;
int rgb[3];
int num_save;
char *colors,*tok_end;
if( ATARI_numpalette==0 && (colors=getenv("GNUCOLORS")) ) {
for( i=0 ; i<16 ; i++ ) {
if( *colors=='\0' ) break;
ATARI_colors[i]=strtoul( colors, &tok_end, 16 );
if( colors==tok_end || (unsigned)ATARI_colors[i]>0xfff ) {
i=0;
break;
}
colors=tok_end;
while( *colors==' ' ) colors++;
}
ATARI_numpalette=i;
}
vdi_handle=graf_handle( &wchar, &hchar, &dummy, &dummy );
for( i=0 ; i<10 ; work_in[i++]=1 );
work_in[10]=2; /* use raster coordinates */
v_opnvwk( work_in, &vdi_handle, work_out );
if( !vdi_handle )
int_error("Fatal error opening virtual workstation", NO_CARET);
term_tbl[term].xmax=work_out[0]+1;
term_tbl[term].ymax=work_out[1]+1;
term_tbl[term].h_char=wchar;
term_tbl[term].v_char=hchar; /* hchar stands for height this time */
term_tbl[term].v_tic=(work_out[1]+1)/80;
term_tbl[term].h_tic=(work_out[0]+1)/80;
ATARI_maxycoord=work_out[1];
ATARI_numcolors=work_out[13];
pxy_index=0;
for( i=0 ; i<ATARI_numpalette ; i++ ) {
vq_color( vdi_handle, i, 1, ATARI_savecolors[i] );
rgb[0]=1000*(ATARI_colors[i]>>8);
rgb[0]/=15;
rgb[1]=1000*((ATARI_colors[i]>>4)&15);
rgb[1]/=15;
rgb[2]=1000*(ATARI_colors[i]&15);
rgb[2]/=15;
vs_color(vdi_handle, i, rgb );
}
}
ATARI_reset( )
{
int i;
if( vdi_handle!=-1 ) {
for( i=0 ; i<ATARI_numpalette ; i++ ) {
vs_color(vdi_handle, i, ATARI_savecolors[i] );
}
v_clsvwk( vdi_handle );
vdi_handle=-1;
}
}
ATARI_graphics( )
{
fflush( stdout );
fflush( stderr );
Cconws( "\033f" ); /* turn cursor off */
v_clrwk( vdi_handle );
pxy_index=0;
}
flush_line( )
{
int line_type;
int color_index;
int i;
if( pxy_index>=2 ) {
if( ATARI_lt<0 ) {
color_index=1; /* black */
line_type=0; /* solid line */
} else {
if( ATARI_numcolors==2 ) { /* Monochrome */
color_index=1;
line_type=ATARI_lt % 4;
} else { /* Color */
color_index=2+ATARI_lt%(ATARI_numcolors-2);
line_type=(ATARI_lt/(ATARI_numcolors-2)) % 4;
}
}
vswr_mode( vdi_handle, MD_TRANS );
vsl_color( vdi_handle, color_index );
switch( line_type ) {
case 0:
vsl_type( vdi_handle, 1 ); /* 1111111111111111 */
break;
case 1:
vsl_type( vdi_handle, 3 ); /* 1110000011100000 */
break;
case 2:
vsl_type( vdi_handle, 5 ); /* 1111111100000000 */
break;
case 3:
vsl_type( vdi_handle, 7 ); /* 1010101010101010 */
vsl_udsty( vdi_handle, 0xaaaa );
break;
}
v_pline( vdi_handle, pxy_index, pxy );
}
if( pxy_index>=1 ) {
pxy[0]=pxy[2*(pxy_index-1)];
pxy[1]=pxy[2*(pxy_index-1)+1];
pxy_index=1;
}
}
ATARI_text( )
{
flush_line( );
Cconws( "\033e" ); /* turn cursor on again */
}
ATARI_move( int x, int y )
{
flush_line( );
pxy_index=1;
pxy[0]=x;
pxy[1]=ATARI_yc(y);
}
ATARI_vector( int x, int y )
{
pxy[2*pxy_index]=x;
pxy[2*pxy_index+1]=ATARI_yc(y);
pxy_index++;
if( pxy_index==64 ) { /* we're all full */
flush_line( );
}
}
ATARI_linetype( int lt )
{
flush_line( );
ATARI_lt=lt;
}
ATARI_put_text( int x, int y, char *str )
{
struct termentry *t=term_tbl+term;
int h_char=t->h_char;
int maxcoord;
int fixcoord;
int dummy;
if( !strlen(str) ) return;
/* align text left and to middle of char height */
vst_alignment( vdi_handle, 0, 1, &dummy, &dummy );
vst_rotation( vdi_handle, (ATARI_rotation ? 900 : 0) );
v_gtext( vdi_handle, x, ATARI_yc(y), str );
}
BOOLEAN ATARI_text_angle( int ang )
{
ATARI_rotation=ang;
return TRUE;
}
BOOLEAN ATARI_justify_text( int mode )
{
return FALSE;
}
ATARI_point( int x, int y, int number )
{
if( ATARI_numcolors==2 ) {
line_and_point( x, y, number ); /* monochrome */
} else {
do_point( x, y, number ); /* color, then */
}
}